All Questions
4 questions
5votes
3answers
5kviews
Sort characters in a Python string by frequency
I wrote a solution to the leetcode problem Sort characters by frequency and the solution passes 34/35 test cases. On the last test case, there is a "time limit exceeded" error with an input string of ...
3votes
2answers
3kviews
"Almost Sorted" coding challenge
The "Almost Sorted" problem from HackerRank: Given an array with \$n\$ elements, can you sort this array in ascending order using only one of the following operations? Swap two elements. ...
4votes
2answers
658views
Counting adjacent swaps to sort an array with 3 different values
This is the Kindergarten Excursion problem from kattis.com: The kindergarten teachers had finally managed to get all the kids in a line for the walk to the bus station and the weekly excursion. What ...
5votes
1answer
4kviews
Ranking players in a league by sorting the contents of an OrderedDict
I'm new to python. I'm having second thoughts on my approach to this problem: The LeagueTable class tracks the score of each player in a league. After each game, the player records their score with ...